<template>
    <div id="qr-box" ref="qrBox">
    </div>
</template>

<script>
  import {QRCode} from '../../../static/js/qrcode'
  export default {
    name: 'qrCode',
    data() {
      return{
        qrCode: null
      }
    },
    props: {
      value: {
        type: String,
        default: 'https://www.jianshu.com/u/42be3945a3bd'
      },
      width: {
        type: [Number,String],
        default: 256
      },
      height: {
        type: [Number,String],
        default: 256
      },
    },
    created() {

    },
    methods: {
      refresh(val) {
        this.qrCode.makeCode(val)
      },
    },
    mounted() {
      let qrCode = new QRCode(this.$refs.qrBox,{
        text: this.value,
        width: this.width,
        height: this.height,
        colorDark : '#000000',
        colorLight : '#ffffff',
        correctLevel : QRCode.CorrectLevel.H
      })
      this.qrCode = qrCode
      // qrCode.makeCode(this.value)
    }
  }
</script>

<style scoped>

</style>
